Upgrade Font Awesome from 5.1.0 to 5.7.2#713
Conversation
|
Why are glyphicons affected? |
@acjh I shifted |
|
What's more efficient? Glyphicons and Font Awesome use separate files right? |
@acjh Right, efficient may not be the right choice of word. What I meant was, the new FA files use On the flip side, since Glyphicons are no longer in Bootstrap, it is unlikely that we would have to change out those files in the future as there is no longer a publicly available version of Glyphicons beyond what used to be in Bootstrap. |
|
Let's not change the original paths. Also, shall we use npm to manage Font Awesome? |
👍 Might I suggest doing
This seems like a good idea, but we would need to change our asset logic to copy from both |
The size bump is only on the MarkBind application side right? When we build the website, we may not need the entire package, we can just copy their Using an npm package may also make upgrading the icons more convenient in the future. |
Yes, that's right. The 13 MB is just an increase in size when a user installs MarkBind. However, built sites will still be the same size.
Agreed. However, I was wondering if the benefit of this outweighs the increase in install size? (given that we don't use most of the Font Awesome package apart from the pre-built files) |
Hmm, I agree that it makes our app a bit more bloated. @Chng-Zhi-Xuan what do you think? |
|
I think going forward to update Font Awesome automatically is necessary, especially if it can reduce manual labour. MarkBind as a product is also operating under some assumptions of our users:
So the 13MB increase in install size is quite trivial given that a 1 minute 720P YouTube video is approximately 40MB already. |
|
I shall try to see how to upgrade Font Awesome with the NPM package then! |
Putting it in this PR is ok. |
|
This PR has been updated to use Font Awesome via the NPM package! |
|
I will take a closer look when I get home at night, but generally I haven't spotted a big issue yet. Meanwhile,
|
Font Awesome stores fonts in webfonts/, while Glyphicons stores fonts in fonts/. To avoid confusion between these two similarly named folders, let's shift Glyphicon files to asset/glyphicons/.
fs-extra-promise#copyAsync creates folders along the destination
if they do not already exist. For example:
fse.copyAsync('file.txt', 'does/not/exist/dest.txt')
will succeed and create the folders "does", "not" and "exist". This
is different from the behaviour of fs.copyFileSync, which raises an
error as the destination folder does not exist. Thus, our test mocks
for copyAsync are incorrect as they rely on the mock for copyFileSync.
Let's create new mocks for copyAsync and copyDirAsync such that their
behaviour matches that of the actual copyAsync.
|
@yamgent commit messages updated! |
Nice work. 👍 Only one minor nit, for commit message in "Copy Font Awesome assets from NPM package", you can drop the word "Currently", it is implied. For commit message in "Return promise directly from copyMarkbindAsset", we could have avoided using the uncommonly heard jargon, by directly explaining the problem with the anti-pattern (the original code is an exercise in futility), but the diff speaks for itself so I am open with leaving the message as it is now. |
- Remove explicit promise construction anti-pattern: https://stackoverflow.com/a/23803744
We include Font Awesome assets by manually copying them to our own package. Since Font Awesome maintains an NPM package, we should copy Font Awesome assets from the NPM package assets for easier maintainence in the future. Let's remove the existing Font Awesome assets in the MarkBind directory and copy them from the NPM package. We should also copy them to _markbind/fontawesome, to prevent confusion with Glyphicon assets.
What is the purpose of this pull request? (put "X" next to an item, remove the rest)
• [X] Enhancement to an existing feature
Fixes #510.
What is the rationale for this request?
With #680, Font Awesome icon names no longer need to be manually hardcoded to be used when referenced with the new colon syntax. As such, we can straightforwardly upgrade our version of Font Awesome by just replacing the CSS and font files. We can also use the
@fortawesome/fontawesome-freeNPM package to keep Font Awesome updated in the future.What changes did you make? (Give an overview)
@fortawesome/fontawesome-free@5.7.2.asset/glyphicons/, to avoid havingfonts/(from Glyphicons) andwebfonts/(from Font Awesome) in the same folder.Site.js#copyFontAwesomeAssetto copy Font Awesome files from the NPM package toasset/fontawesome/.fs.copyAsync()mock to match its actual behaviour (details in 8e438cb)Provide some example code that this change will affect:
- FA new icons: :fab-markdown: :fas-biohazard:Testing instructions: